package servlet;
import servlet.Connections;
import java.sql.*;
import java.io.*;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class EditDeveloper
 */
public class EditDeveloper extends HttpServlet {
	private static final long serialVersionUID = 1L;

	Connections conn=new Connections();
	//	Statement stmt=null;
		PreparedStatement pstmt=null;
		ResultSet rs=null;
		String name,phone,email,address,query,developerName;
		
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
	{
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
	{

		PrintWriter out=response.getWriter();
		
		developerName=request.getParameter("developer");
		name=request.getParameter("nametxt");
		phone=request.getParameter("phonetxt");
		email=request.getParameter("emailtxt");
		address=request.getParameter("address");
		out.println(developerName);
		out.println(name);
		out.println(phone);
		out.println(email);
		out.println(address);
		int queryupdate;
		//query="UPDATE Developer SET developer_Name='"+name+"'"+"SET phone='"+phone+"'"+"SET E_Mail='"+"'"+"SET Developer_Address='"+address+"'";
		 query="UPDATE Developer SET developer_Name=?"+",phone=?"+",E_Mail=?"+",Developer_Address=?"+" where developer_name='"+developerName+"'";
		out.println(query);
		
		
		
		
		try
		{
			
			pstmt=conn.getConnection().prepareStatement(query);
			pstmt.setString(1, name);
			pstmt.setString(2,phone);
			pstmt.setString(3,email);
			pstmt.setString(4,address);
			queryupdate=pstmt.executeUpdate();
			if(queryupdate!=0)
				out.println("Data Saved");
			else
				out.println("Data not saved");
			
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}

	}

}
